package com.lavida.project.system.review.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lavida.project.system.emp.domain.Emp;
import com.lavida.project.system.emp.mapper.EmpMapper;
import com.lavida.project.system.review.domain.Penalty;
import com.lavida.project.system.review.domain.Review;
import com.lavida.project.system.review.mapper.PenaltyMapper;
import com.lavida.project.system.review.mapper.ReviewMapper;

@Service
public class PenaltyServiceImpl implements PenaltyService{
	@Autowired
	private PenaltyMapper penaltyMapper;
	
	@Autowired
	private EmpMapper empMapper;
	@Override
	public List<Penalty> selectPenalty(Penalty penalty) {
		// TODO Auto-generated method stub
		return penaltyMapper.selectPenalty(penalty);
	}
	@Override
	public long addPenalty(Penalty penalty) {
		// TODO Auto-generated method stub
		/*if(penalty.getJob_id()!=null) {
			Emp emp = empMapper.selectByJob_id(Integer.parseInt(penalty.getJob_id()));
			Double salra =0.0;
			if(penalty.getSalaryChange()!=null) {
				salra =Double.parseDouble(penalty.getSalaryChange());
			}
			emp.setTaxbefore(emp.getTaxbefore()+salra);
		}*/
		return penaltyMapper.addPenalty(penalty);
	}
	@Override
	public void deletePenalty(int[] ids) {
		// TODO Auto-generated method stub
		for(int i =0;i<ids.length;i++) {
			/*Penalty penalty = penaltyMapper.getPenalty(ids[i]);
			Double salra =0.0;
			if(penalty.getJob_id()!=null) {
				Emp emp = empMapper.selectByJob_id(Integer.parseInt(penalty.getJob_id()));
				Double salras = emp.getTaxbefore();
				if(penalty.getSalaryChange()!=null) {
					salra =Double.parseDouble(penalty.getSalaryChange());
				}
				emp.setTaxbefore(salras-salra);
			}*/
			penaltyMapper.deletePenalty(ids[i]);
		}
		
	}
	@Override
	public Penalty getPenalty(int id) {
		// TODO Auto-generated method stub
		return penaltyMapper.getPenalty(id);
	}
	@Override
	public long updatePenalty(Penalty penalty) {
		// TODO Auto-generated method stub
		return penaltyMapper.updatePenalty(penalty);
	}

}
